<template>
  <el-dialog
    :visible="visible"
    @close="$emit('close')"
    width="95%"
    center
    title="分组名单"
    class="g-Result"
    :show-close="false"
    :append-to-body="true"
  >
    <div class="container" v-for="(item, index) in groupMembers" :key="index">
      <div class="title">第{{ index + 1 }}组</div>
      <div class="scroll-view">
        <div class="item" v-for="(data, j) in item" :key="j">
          <div class="left">
            <span>第{{ data.key }}号</span>
          </div>
          <div class="right">
            <span class="red">{{ data.name }}</span>
          </div>
        </div>
      </div>
      <div class="empty" v-if="groupMembers.length == 0">暂未分组</div>
    </div>
  </el-dialog>
</template>

<script>
export default {
  props: {
    groupMember: {
      type: Array,
      default: () => []
    },
    visible: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      groupMembers: []
    };
  },
  watch: {
    visible(newVal) {
      if (newVal) {
        if (this.groupMember.length) {
          this.groupMembers = this.groupMember;
        } else {
          this.groupMembers = JSON.parse(localStorage.getItem('groupMember'));
        }
      }
    }
  }
};
</script>

<style lang="scss">
.g-Result {
  .el-dialog {
    padding: 0 0 20px;
    overflow: hidden;
    border-radius: 14px;
    background: linear-gradient(0deg, #24cac2, #1dd7bc);
    box-shadow: 0px 35px 50px 0px rgba(223, 255, 252, 0.35);
  }
  .el-dialog__title {
    color: #fff;
    width: 80%;
    line-height: 1;
    padding: 12px 0;
    margin: 0 auto;
    display: block;
    font-size: 34px;
    background: #009f9e;
    border-radius: 14px;
  }
  .el-dialog__body {
    width: 95%;
    overflow-y: auto;
    margin: 20px auto;
    max-height: 75vh;
    background: #ffffff;
    border-radius: 14px;
	display: flex;
	justify-content: center;
	flex-wrap: wrap;
    padding: 0 0 20px !important;
    box-shadow: 0px 6px 0px 0px rgba(0, 159, 158, 0.53),
      0px 7px 66px 0px #d1fffb;
    .container {
      min-width: 11%;
      padding: 20px;
      box-sizing: border-box;
      .empty {
        color: #999;
        font-size: 24px;
        text-align: center;
      }
      .title {
        color: #fff;
        padding: 5px 0;
        font-size: 32px;
        margin: 0 0 10px;
        text-align: center;
        border-radius: 6px;
        background: linear-gradient(0deg, #24cac2, #1dd7bc);
        box-shadow: 0px 35px 50px 0px rgba(223, 255, 252, 0.35);
      }
      .scroll-view {
        max-height: 68vh;
        overflow-y: auto;
		padding: 0 15px;
      }
      .item {
        color: #333;
        overflow: hidden;
        font-size: 30px;
        margin: 0 0 18px;
        span {
        }
        .red {
          color: #fa4727;
        }
        .left {
          width: 50%;
          float: left;
          padding-right: 10px;
          box-sizing: border-box;
        }
        .right {
          width: 50%;
          float: right;
          text-align: right;
        }
      }
    }
  }
}
</style>
